#include<stdio.h>

int year(int yyyy);
int main()
{
    int yyyy, mm, dd;
    int day;
    scanf("%d/%d/%d",&yyyy, &mm, &dd);
    if(mm == 1)
    {
        day = dd;
    }
    else if(mm == 2)
    {
        day = 31 + dd;
    }
    else if(mm == 3)
    {
        if(year(yyyy))
        {
            day = 31 + 29 + dd;
        }
        else
        {
            day = 31 + 28 + dd;
        }
        
    }
    else if(mm == 4)
    {
        if(year(yyyy))
        {
            day = 31 + 29 + 31 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + dd;
        }
    }
    else if(mm == 5)
    {
       if(year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + dd;
        }
    }
    else if(mm == 6)
    {
        if(year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + dd;
        }
    }
    else if(mm == 7)
    {
        if(year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + 30 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + 30 + dd;
        }
    }
    else if(mm == 8)
    {
        if(year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + 30 + 31 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + 30 + 31 + dd;
        }
    }
    else if(mm == 9)
    {
        if (year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + dd;
        }
    }
    else if(mm == 10)
    {
        if (year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + dd;
        }
    }
    else if(mm == 11)
    {
        if (year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + dd;
        }
    }
    else if(mm == 12)
    {
        if (year(yyyy))
        {
            day = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + dd;
        }
        else
        {
            day = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + dd;
        }
    }
    printf("%d",day);

    return 0;
}

int year(int yyyy)
{
    int n = 0;
    if(yyyy%4 == 0 && yyyy%100 != 0 || yyyy%400 == 0)
    {
        n = 1;
    }
    return n;
}